﻿#ifndef QPARAMBASICWIDGET_H
#define QPARAMBASICWIDGET_H

#include <QWidget>
#include <qfile.h>
#include "capcontroldefine.h"

typedef  struct _pid
{
    float lfKP=0.0;
    float lfKI=0.0;
    float lfKD=0.0;
}st_pid;

class QParamBasicWidget : public QWidget
{
    Q_OBJECT
public:
    explicit QParamBasicWidget(QWidget *parent = nullptr);

    void parsePIDParam(st_pid_frame& framedata);

    void parseParam(st_loopbackdata& framedata);

    QString getFrameStatus(st_loopbackdata& framedata);

    void saveDataToFile();

    void writeDataToFile(QString str);

    QMap<int,QString> _errCodeInfo;

public:
    st_loopbackdata _rcvframedata;

    int _i32FrameCnt;

    st_pid m_st_current_pid;//电流环参数
    st_pid m_st_speed_pid;//速度环参数
    st_pid m_st_pos_pid;//位置环参数

    float _lfPosForwardGain;//位置环前馈速度增益

    float _lfSpeedForwardGain;//速度环前馈速度增益
    int _i32SpeedForwardEnable;//速度环前馈速度增益

    float _lfInputSaturMax;//输入饱和度限制
    float _lfOutputSaturMax;//输出饱和度限制

    bool _bStartTest;

    float _lfACurrentdata;
    float _lfBCurrentdata;
    float _lfCurrentdata;

    float _lfMotorTemplate;
    float _lfIPMTemplate;

    float _lfQSetdata;
    float _lfQResponsedata;

    float _lfSpeedSetdata;
    float _lfSpeedRespdata;

    float _lfPosSetdata;
    float _lfPosRespdata;


    QFile m_savefile;

    QString m_sSaveDataInfo;

    bool _bStartSaveData;
    int _i32SaveFrameCnt;
signals:
    void signal_setpid(int i32AxisNo,int nType,float lfparam);//设置参数

    void signal_getpid(int i32AxisNo,int cmdid);//查询参数

public slots:


};

#endif // QPARAMBASICWIDGET_H
